/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2024-02-02
 * Time: 15:12
 *
 * https://www.nowcoder.com/share/jump/7745334641706857927023
 */
public class BM93 {
    public int maxArea(int[] height) {
        if (height == null || height.length < 2) {
            return 0;
        }
        // 左右指针
        int left = 0, right = height.length - 1;
        // 容量
        int capacity = 0;
        while (left < right) {
            // 计算当前的容量
            int tmp = (right - left) * Math.min(height[left], height[right]);
            capacity = Math.max(capacity, tmp);
            // 移动左右指针，留下较长的边
            if (height[left] < height[right]) {
                left++;
            } else {
                right--;
            }
        }
        return capacity;
    }
}
